package com.lhkj.ct.meta.modules.gauge.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lhkj.ct.base.model.dto.PageQuery;
import com.lhkj.ct.meta.modules.gauge.model.entity.TblQnr;
import com.lhkj.ct.meta.modules.gauge.model.vo.QnrPageVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 调查问卷 Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2023-10-26
 */
public interface QnrMapper extends BaseMapper<TblQnr> {

    @Select("select t.id, t.qnr_name, t.introduction, t.instruction, t1.id as category,t2.id as usability, t1.c_name, t2.u_name, t.question_json from tbl_qnr t " +
            "left join tbl_gauge_category t1 on t1.id = t.category " +
            "left join  tbl_gauge_usability t2 on t2.id = t.usability " +
            "where t.id = #{id,jdbcType=VARCHAR} and t.del_flag = 0 ")
    TblQnr getForm(@Param("id") String id);

    IPage<QnrPageVo> selectQnrPage(Page<TblQnr> page, @Param("qnr") TblQnr qnr, @Param("pageQuery") PageQuery pageQuery);

    List<Map<String, List<Map<String, Object>>>> groupByCategory(@Param("qnr") TblQnr qnr);
}
